$NG.AllReady(function (page, { useAction, useBeforeClick, useValuesChange, useClick, useUpdateRow, subscribe, useUpdateRows }) {
    const mstform = $NG.getCmpApi("BaseInfo")
    const dgrid1 = $NG.getCmpApi("")
    const getHeadValue = (str) => mstform.getItem(str).getValue()
    //init 

    useValuesChange(()=>{
        getSupplyInfo()
    },"user_gysmc")

    useUpdateRow(({args})=>{
        console.log(`bianji`,);
        const row = args[0]
        if(!Number.isInteger((Number(row.Qty) || 0))){
            $NG.alert("设备数量应为整数!")
            row.Qty = 0
        }
    },"ContractList")

    // 获取供应商信息
    function getSupplyInfo(){
        const phid = mstform.getItem("user_gysmc").getValue()
        if(!phid) return 
        $NG.execServer("getSupplyInfo",{phid},(res)=>{
            if(res.count == 0) return 
            const data = JSON.parse(res.data)[0].extendObjects
            const arr = [
                {
                    key:'user_nsrsbh',
                    value:data.unisocialcredit
                },
                {
                    key:'user_khh',
                    value:data.taxbank_name
                },
                {
                    key:'user_zh',
                    value:data.taxaccountno
                },
                {
                    key:'user_dz',
                    value:data.taxaddress
                },
                {
                    key:'user_dh',
                    value:data.taxtelephone
                },
                {
                    key:'user_lxr',
                    value:data.taxpayername
                },
                {
                    key:'user_sx',
                    value:data.user_sx
                },{
                    key:'user_hh',
                    value:{
                        label:data.taxbank_no,
                        value:data.taxbank_id
                    }
                }
            ]
            setHeadValue(arr)
        })
    }

    // 赋值
    function setHeadValue(datas){
        datas.forEach(item=>{
            try{
                mstform.getItem(item.key).setValue(item.value)
            }catch(err){
                console.log(`err`,err,item);
            }
        })
    }
})